export default function({ app: { $axios, $cookies }}) {
  $axios.defaults.baseURL = process.env.API_BASE_API
  $axios.defaults.timeout = 30000
  $axios.interceptors.request.use(config => {
    config.headers['Accept'] = 'application/json'
    config.headers['Accept'] = 'application/prs.xiaomei.v1+json'
    if ($cookies.get('user_token')) {
      config.headers['Authorization'] = 'Bearer ' + $cookies.get('user_token')
    }
    return config
  })
  $axios.interceptors.response.use(response => {
    // if (/^[4|5]/.test(response.status)) {
    //   return Promise.reject(response.statusText)
    // }
    return response
  })
}
